home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 626-637 / disk_632 / printfiles / source / prf_apphandler.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  9KB  |  221 lines

  1. /* prf_apphandler.c */
  2. /* V1.1 9-3-92 */
  3.  
  4. #include "prf.h"
  5.  
  6. UWORD chip iconI1Data[] =
  7. {
  8. /* Plane 0 */
  9.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  10.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  11.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  12.     0x0000,0x0000,0x1000,0x0000,0x0020,0x0000,0x0000,0x007F,
  13.     0xF000,0x0000,0x0000,0x0000,0x1002,0x0000,0x0020,0x0000,
  14.     0x0000,0x00CB,0xE000,0x0000,0x0000,0x0000,0x1000,0x0000,
  15.     0x0020,0x0000,0x0000,0x00FB,0xBA04,0x0000,0x0000,0x0000,
  16.     0x1000,0x0000,0x0020,0x0000,0x0000,0x00DE,0x6F00,0x0000,
  17.     0x0000,0x0000,0x1000,0x0000,0x0020,0x0000,0x0000,0x00B0,
  18.     0x0000,0x0000,0x0000,0x0000,0x1000,0x0000,0x0020,0x0000,
  19.     0x0000,0x00C1,0x17BE,0x3000,0x0000,0x0000,0x10E1,0x8000,
  20.     0x0020,0x0000,0x0000,0x0012,0x1C00,0x0000,0x0000,0x0000,
  21.     0x1000,0x0000,0x0020,0x0000,0x003F,0xFFFF,0xFFFF,0xFFFF,
  22.     0xF000,0x00FF,0xFFFF,0xFFFE,0xE077,0xFF80,0x00FF,0xFFFF,
  23.     0xFFFD,0x5EE9,0xFF80,0x00FF,0xFFFF,0xFFFF,0xF7FF,0xFF80,
  24.     0x00FF,0xFFFF,0xFFFF,0xDFFF,0xFF80,0x00FF,0xFFFF,0xFFFF,
  25.     0xFFFF,0xFC00,0x01FF,0xFFFF,0xFFFF,0xFFFF,0xFC00,0x02FF,
  26.     0xFFFF,0xFFFF,0xFFFF,0xFC00,0x033E,0x0000,0x0000,0x0003,
  27.     0xE000,0x00F0,0x0000,0x0000,0x0000,0x0000,0x000C,0x0000,
  28.     0x0000,0x0000,0x0000,0x0018,0x0000,0x0000,0x0000,0x0000,
  29.     0x0060,0x0000,0x0000,0x0000,0x0000,0xFF80,0x0000,0x0000,
  30.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  31.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  32.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  33.     0x0000,0x0000,0x0000,
  34. /* Plane 1 */
  35.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  36.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  37.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  38.     0x0000,0x0000,0x2FFF,0xFFFF,0xFFD0,0x0000,0x0000,0x3F80,
  39.     0x0FFF,0xFFF0,0x0000,0x0000,0x2FFD,0xFFFF,0xFFD0,0x0000,
  40.     0x0000,0x3F34,0x1FFF,0xFFF0,0x0000,0x0000,0x2FFF,0xFFFF,
  41.     0xFFD0,0x0000,0x0000,0x3F04,0x45FB,0xFFF0,0x0000,0x0000,
  42.     0x2FFF,0xFFFF,0xFFD0,0x0000,0x0000,0x3F21,0x90FF,0xFFF0,
  43.     0x0000,0x0000,0x2FFF,0xFFFF,0xFFD0,0x0000,0x0000,0x3F4F,
  44.     0xFFFF,0xFFF0,0x0000,0x0000,0x2FFF,0xFFFF,0xFFD0,0x0000,
  45.     0x0000,0x3F3E,0xE841,0xCFF0,0x0000,0x0000,0x2F1E,0x7FFF,
  46.     0xFFD0,0x0000,0x0000,0x3FED,0xE3FF,0xFFF0,0x0000,0x0000,
  47.     0x2FFF,0xFFFF,0xFFD0,0x0000,0x0000,0x0000,0x0000,0x0000,
  48.     0x0000,0x0000,0x0000,0x0001,0x1F88,0x0780,0x0000,0x0000,
  49.     0x0002,0xA116,0x0780,0x0000,0x0000,0x0000,0x0800,0x0780,
  50.     0x0000,0x0000,0x0000,0x2000,0x0780,0x0000,0x0000,0x0000,
  51.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  52.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0700,0x0000,
  53.     0x0000,0x0000,0x0000,0x7FE0,0x0000,0x0000,0x0000,0x0003,
  54.     0xFFFC,0x0000,0x0000,0x0000,0x001F,0xFFFF,0x8000,0x0000,
  55.     0x0000,0x01FF,0xFFFF,0xF000,0x0000,0x0000,0x0FFF,0xFFFF,
  56.     0xFE00,0x0000,0x0000,0x3FFF,0xFFFF,0xFF80,0x0000,0x0000,
  57.     0x001F,0xFFFF,0x8000,0x0000,0x0000,0x001F,0xFFFF,0x8000,
  58.     0x0000,0x0000,0x001F,0xFFFF,0x8000,0x0000,0x0000,0x001F,
  59.     0xFFFF,0x8000,0x0000,
  60. /* Plane 2 */
  61.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  62.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  63.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  64.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  65.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  66.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  67.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  68.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  69.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  70.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  71.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  72.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  73.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  74.     0x0000,0x0003,0x8000,0x0000,0x0000,0x0000,0x0003,0x8000,
  75.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  76.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  77.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
  78.     0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0700,0x0000,
  79.     0x0000,0x0000,0x0000,0x7FE0,0x0000,0x0000,0x0000,0x0003,
  80.     0xFFFC,0x0000,0x0000,0x0000,0x001F,0xFFFF,0x8000,0x0000,
  81.     0x0000,0x01FF,0xFFFF,0xF000,0x0000,0x0000,0x0FFF,0xFFFF,
  82.     0xFE00,0x0000,0x0000,0x3FFF,0xFFFF,0xFF80,0x0000,0x0000,
  83.     0x001F,0xFFFF,0x8000,0x0000,0x0000,0x001F,0xFFFF,0x8000,
  84.     0x0000,0x0000,0x001F,0xFFFF,0x8000,0x0000,0x0000,0x001F,
  85.     0xFFFF,0x8000,0x0000,
  86. };
  87.  
  88. struct Image iconI1 =
  89. {
  90.     0, 0,                       /* Upper left corner */
  91.     73, 39, 3,                  /* Width, Height, Depth */
  92.     iconI1Data,             /* Image data */
  93.     0x0007, 0x0000,             /* PlanePick, PlaneOnOff */
  94.     NULL                        /* Next image */
  95. };
  96.  
  97. struct DiskObject icon =
  98. {
  99.     WB_DISKMAGIC,               /* Magic Number */
  100.     WB_DISKVERSION,             /* Version */
  101.     {                           /* Embedded Gadget Structure */
  102.         NULL,                   /* Next Gadget Pointer */
  103.         0, 0, 73, 40,           /* Left,Top,Width,Height */
  104.         GADGIMAGE | GADGHCOMP,  /* Flags */
  105.         RELVERIFY,              /* Activation Flags */
  106.         BOOLGADGET,             /* Gadget Type */
  107.         (APTR)&iconI1,      /* Render Image */
  108.         NULL,                   /* Select Image */
  109.         NULL,                   /* Gadget Text */
  110.         NULL,                   /* Mutual Exclude */
  111.         NULL,                   /* Special Info */
  112.         0,                      /* Gadget ID */
  113.         NULL,                   /* User Data */
  114.     },
  115.     WBTOOL,                     /* Icon Type */
  116.     NULL,                       /* Default Tool */
  117.     NULL,                       /* Tool Type Array */
  118.     NO_ICON_POSITION,           /* Current X */
  119.     NO_ICON_POSITION,           /* Current Y */
  120.     NULL,                       /* Drawer Structure */
  121.     NULL,                       /* Tool Window */
  122.     0                           /* Stack Size */
  123. };
  124.  
  125. long OpenApp(struct prf_info *info)
  126. {
  127.  if(info->appPort = CreateMsgPort())
  128.  {
  129.   info->appPort->mp_Node.ln_Pri  = 0;
  130.   if(info->amenu = AddAppMenuItem(0,0,(UBYTE *)T_MENUITEM,info->appPort,TAG_DONE))
  131.   {
  132.    if(info->aicon = AddAppIcon(0,0,(UBYTE *)T_APPICON,info->appPort,NULL,&icon,TAG_END))
  133.    {
  134.     return ((long)TRUE);
  135.    }
  136.   }
  137.  }
  138.  return ((long)FALSE);
  139. }
  140.  
  141. void CloseApp(struct prf_info *info)
  142. {
  143.  if(info->appPort)
  144.  {
  145.   if(info->aWnd)  RemoveAppWindow(info->aWnd);
  146.   if(info->amenu) RemoveAppMenuItem(info->amenu);
  147.   if(info->aicon) RemoveAppIcon(info->aicon);
  148.   while(info->amsg = (struct AppMessage *)GetMsg(info->appPort))
  149.    ReplyMsg((struct Message *)info->amsg);
  150.   DeleteMsgPort(info->appPort);
  151.  }
  152. }
  153.  
  154. void ChangeApp(struct prf_info *info)
  155. {
  156.  if(!info->Swd)
  157.  {
  158.   if(OpenSwd(info))
  159.   {
  160.    info->aWnd = AddAppWindow(0,0,info->Swd,info->appPort,TAG_DONE);
  161.   }
  162.  }
  163.  else
  164.  {
  165.   if(info->aWnd)
  166.   {
  167.    RemoveAppWindow(info->aWnd);
  168.    info->aWnd = NULL;
  169.   }
  170.   CloseSwd(info);
  171.  }
  172. }
  173.  
  174. long HandleAmsg(struct prf_info *info)
  175. {
  176.  ULONG i;
  177.  UBYTE f[256];
  178.  long rc = CMD_NEUTRAL;
  179.  switch(info->amsg->am_Type)
  180.  {
  181.   case  MTYPE_APPICON    : if(info->amsg->am_NumArgs != 0)
  182.                            {
  183.                             for(i = 0; i < info->amsg->am_NumArgs;i++)
  184.                             {
  185.                              long cmd = CMD_INSERTTAIL;
  186.                              NameFromLock(info->amsg->am_ArgList[i].wa_Lock,f,256);
  187.                              AddPart(f,info->amsg->am_ArgList[i].wa_Name,256);
  188.                              info->Special1 = (APTR)f;
  189.                              info->Special2 = (APTR)&cmd;
  190.                              InsertName(info);
  191.                              info->Special1 = NULL;
  192.                              info->Special2 = NULL;
  193.                             }
  194.                             if(!(info->Swd))rc = CMD_PRINT;
  195.                              else rc = CMD_NEUTRAL;
  196.                            }
  197.                            else
  198.                            rc = CMD_CHANGEAPP;
  199.                            break;
  200.   case  MTYPE_APPWINDOW  : for(i = 0; i < info->amsg->am_NumArgs;i++)
  201.                            {
  202.                             long cmd = CMD_INSERTTAIL;
  203.                             NameFromLock(info->amsg->am_ArgList[i].wa_Lock,f,256);
  204.                             AddPart(f,info->amsg->am_ArgList[i].wa_Name,256);
  205.                             info->Special1 = (APTR)f;
  206.                             info->Special2 = (APTR)&cmd;
  207.                             InsertName(info);
  208.                             info->Special1 = NULL;
  209.                             info->Special2 = NULL;
  210.                            }
  211.                            rc = CMD_NEUTRAL;
  212.                            break;
  213.   case MTYPE_APPMENUITEM : rc = CMD_CHANGEAPP;
  214.                            break;
  215.   default                : rc = CMD_NEUTRAL;
  216.                            break;
  217.  }
  218.  return (rc);
  219. }
  220.  
  221.